package com.squirrel.michale;

import java.util.ArrayList;
import java.util.List;

/**
 * @author guanhao 观浩
 * @version 1.0.0.0
 * @createTime 2023/2/23 8:16 PM
 * @company Michale Squirrel
 * @link
 * @description
 */
public class DataStream2 {

    int value;
    int k;

    List<Integer> integerList = new ArrayList<>();

    public DataStream2(int value, int k) {

        this.value = value;
        this.k = k;

    }

    public boolean consec(int num) {
        integerList.add(num);
        if (integerList.size() < k) {
            return false;
        } else {
            boolean allEqual = true;
            for (int i = integerList.size() - 1; i >= integerList.size() - k; i--) {
                if (integerList.get(i) != value) {
                    allEqual = false;
                }
            }
            return allEqual;
        }
    }
}
